package main

import (
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/orm"
	_ "github.com/go-sql-driver/mysql"
	_ "smallgift/routers"
)

func initModel() {
	if beego.AppConfig.String("runmode") == "dev" {
		orm.Debug = true
	}

	//注册数据库驱动
	orm.RegisterDriver("mysql", orm.DRMySQL)
	dblink := ""
	if beego.AppConfig.String("runmode") == "dev" {
		dblink = "root:root123@tcp(127.0.0.1:3306)/huijing?charset=utf8&loc=Asia%2FShanghai" //120.24.43.187
	} else {
		dblink = "miaofu:Miaofu12345@tcp(rm-uf63e37r8s8bewe56.mysql.rds.aliyuncs.com:3306)/huijingpos?charset=utf8&loc=Asia%2FShanghai"
	}
	orm.RegisterDataBase("default", "mysql", dblink)
	orm.RunSyncdb("default", false, true)
}

func init() {
	beego.Debug("maininit")
	initModel()
}

func main() {
	beego.Run()

}

